package com.hilaver.dzmis.service.impl;

import com.hilaver.dzmis.service.AbstractBaseService;
import com.hilaver.dzmis.service.IEntityService;
import com.hilaver.dzmis.sys.SysMenu;

public class SysMenuServiceImpl extends AbstractBaseService implements IEntityService {

	@Override
	public String delete(int id) throws Exception {
		return super.delete(SysMenu.class.getName(), id);
	}

	public String edit(Object obj) throws Exception {
		SysMenu menu = (SysMenu)obj;
		SysMenu old = (SysMenu)this.dao.get(SysMenu.class.getName(), menu.getId());
		old.getSysMenus();
		this.dao.getSession().evict(old);
		
		old.setDescriptionCn(menu.getDescriptionCn());
		old.setDescriptionEn(menu.getDescriptionEn());
		old.setDescriptionFr(menu.getDescriptionFr());
		
		this.dao.saveOrUpdate(old);
		return "{success: true}";
	}
	
	@Override
	public String get(int id) throws Exception {
		return super.get(SysMenu.class.getName(), id);
	}

	@Override
	public String getAllPagination(int page, String sort, String order)
			throws Exception {
		return super.getAllPagination(SysMenu.class.getName(), page, sort, order);
	}
	
	public String getAllPagination(int page, String sort, String order, String[] filters)
	throws Exception {
	return super.getAllPagination(SysMenu.class.getName(), page,
				sort, order, filters);
	}

	public String getAll(String sort, String order) throws Exception {
		return super.getAll(SysMenu.class.getName(), sort, order);
	}

}
